package com.interagriculture.controller;

import com.interagriculture.common.PageResult;
import com.interagriculture.common.Result;
import com.interagriculture.entity.Journalism;
import com.interagriculture.entity.vo.JournalismDetailVO;
import com.interagriculture.entity.vo.JournalismVO;
import com.interagriculture.service.JournalismService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * (Journalism)表控制层
 *
 * @author makejava
 * @since 2024-11-14 15:52:14
 */
@RestController
@RequestMapping("/journalism")
public class JournalismController {
    /**
     * 服务对象
     */
    @Resource
    private JournalismService journalismService;

    /**
     * 获取新闻列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getJournalism")
    public Result<List<Journalism>> getJournalism(){
        List<Journalism> journalismList = journalismService.queryJournalismByPage();
        return Result.ok(journalismList);
    }

    /**
     * 获取某篇新闻的详细信息
     * @param id
     * @return
     */
    @GetMapping("/getJournalismById")
    public Result<JournalismDetailVO> getJournalismById(Integer id){
        JournalismDetailVO journalismDetailVO = journalismService.queryDetailJournalismById(id);
        return Result.ok(journalismDetailVO);
    }
}

